#ifndef __DAQ_POC_H__
#define __DAQ_POC_H__

#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <assert.h>
#include <omp.h>
#include <windows.h>
#include <cv.h>
#include <highgui.h>
#include "NIDAQmx.h"
#include "CaPIICam.h"

/*------------------------*/

#define CAP_LEN 	4.0
#define VID_FPS 	1000
#define VID_H		400
#define VID_W		800
#define VID_LEN		(int)(CAP_LEN*VID_FPS)
#define VID_BUFF_LEN \
	(int)(CAP_LEN*VID_H*VID_W*VID_FPS)
#define DAQ_HZ  	1000
#define DAQ_UPDATE_TIME	(1.0/VID_FPS)
#define DAQ_N_BLOCKS \
	(int)(CAP_LEN/DAQ_UPDATE_TIME)
#define DAQ_DEV_N_CHAN 	3
#define DAQ_BLOCK_LEN \
	(int)(DAQ_UPDATE_TIME*DAQ_DEV_N_CHAN*DAQ_HZ)
#define DAQ_SIG_LEN	(DAQ_BLOCK_LEN*DAQ_N_BLOCKS)
#define DAQ_BUFF_LEN \
	(int)((2*DAQ_N_BLOCKS-1)*DAQ_UPDATE_TIME*\
	DAQ_DEV_N_CHAN*DAQ_HZ)
#define	DAQ_VOLT_RANGE 	5.0
#define DAQ_L_SERIAL	21692874
#define DAQ_R_SERIAL	25233189

struct param_struct {
	float	capture_length;
	int32_t	force_sample_rate;
	int32_t	video_frame_rate;
};

struct dev_struct {
	CCaPIICam 	video;
	char*		daq_chan_L;
	char*		daq_chan_R;
	TaskHandle	force_L;
	TaskHandle	force_R;
};

struct buffer_struct {
	double force_L[DAQ_BUFF_LEN];
	double force_R[DAQ_BUFF_LEN];
	int32_t	force_ptr;
	int8_t video[VID_BUFF_LEN];
	int32_t video_ptr;
};

struct param_struct 	PARAM;
struct dev_struct 	DEV;
struct buffer_struct 	BUFFER;

/* SWITCHES */

int8_t SW_TERMINATE = 0;
int8_t SW_ACQ_LIVE = 0;

/* FUNCTION DIRECTORY */

void initParams(
	);
void setupDevs(
	);
void startDevs(
	);
void maintainBuffers(
	);
void waitForKey(
	);
void stopDevs(
	);
void writeFile(
	);
void killDevs(
	);
void diagDAQ(
	int 	err
	);

#endif//__DAQ_POC_H__
